import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


public class StudentPlanning extends JPanel{
	JTabbedPane panel;
	JPanel basePanel;
	JPanel back;
	Image img;
	
	public StudentPlanning(){
		//entire interface
		//fix the loc change error
		//setLayout(new BorderLayout());
		//add(panel,BorderLayout.PAGE_START);
		img=new ImageIcon("login_background.png").getImage();
		setOpaque(false);
		
		basePanel=new JPanel();
		basePanel.setLayout(new BorderLayout());
		basePanel.setBackground(Color.WHITE);
		basePanel.setOpaque(false);
		panel=new JTabbedPane();
		panel.setBackground(Color.WHITE);
		//panel.setOpaque(false);
		setBackground(Color.WHITE);
		//basePanel.setPreferredSize(new Dimension(600,400));
		panel.setPreferredSize(new Dimension(600,400));
		
		back=new JPanel();
		//if back tab clicked, jump to main menu panel.
		JPanel menu=new JPanel();
		
		panel.addTab("Home",new StudentHomePanel());
		panel.addTab("My Progress",new MyProgressPanel());
		panel.addTab("Course Catalog",new CatalogPanel());
		panel.addTab("Back to Menu", menu);
		
		panel.addChangeListener(new ChangeListener() {
	        public void stateChanged(ChangeEvent e) {
	        	if (e.getSource() instanceof JTabbedPane) {
	        		if(panel.getSelectedIndex()==3){
	        			remove(basePanel);
	        			add(new MenuPanel());
	        			validate();
	        			repaint();	        			
	        		}
                }
	        }
	    });
		
		setLayout(new BorderLayout());
		basePanel.add(panel,BorderLayout.PAGE_START);
		add(basePanel, BorderLayout.PAGE_START);
	}
	
	

	@Override
    public void paintComponent(Graphics g) {
		super.paintComponents(g);
        g.drawImage(img, 0, 0, this);
    }
}
